//
//  DengLuView.m
//  GOGOTravel
//
//  Created by dllo on 16/2/23.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "DengLuView.h"
#import "UMSocial.h"
#import "SanFangDengLuViewController.h"
@interface DengLuView ()<UMSocialUIDelegate>

@property (nonatomic, retain) UIView *dengLuView;
@property (nonatomic, retain) UIView *view;/**<  弹出的view */
@property (nonatomic, retain) UIView *viewZuCe;/**<  注册界面 */
@property (nonatomic, retain) UITextField *userNMTF;
@property (nonatomic, retain) UITextField *mImATF;
@property (nonatomic, retain) UIView *alertView;
@property (nonatomic, retain) UILabel *label;
@property (nonatomic, retain) SanFangDengLuViewController *sanfang;

@end

@implementation DengLuView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _isOut = NO;
        [self createView];
        
        self.sanfang = [[SanFangDengLuViewController alloc] init];
        
        self.bolck = ^(BOOL isOut){
            _isOut = isOut;
        };
    }
    return self;
}



- (void)dealloc{
    [_dengLuView release];
    [super dealloc];
}

- (void)createView{
    //登陆界面
    self.dengLuView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    _dengLuView.backgroundColor = UIColorFromRGB(0x099cc);
    [self addSubview:_dengLuView];
    [_dengLuView release];
    
    [self CreateView];
}

- (void)CreateView{
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width - 200)/2, 100, 200, 80)];
    label.text = @"你好，面粉!";
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:30];
    
    [_dengLuView addSubview:label];
    [label release];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/3 - 80, 180, 50, 50);
    [button setBackgroundImage:[UIImage imageNamed:@"iconfont-weixin.png"] forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(buttonActionWeiXin:) forControlEvents:UIControlEventTouchUpInside];
    [_dengLuView addSubview:button];
    
    UILabel *labelWX = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/3 - 80, 225, 50, 30)];
    labelWX.text= @"人人登录";
    labelWX.textColor = [UIColor whiteColor];
    labelWX.backgroundColor = [UIColor clearColor];
    labelWX.font = [UIFont systemFontOfSize:12];
    
    [self addSubview:labelWX];
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(button.frame.size.width  + [UIScreen mainScreen].bounds.size.width/3 - 80 + 60, 180, 50, 50);
    [button1 setBackgroundImage:[UIImage imageNamed:@"iconfont-xinlangweibo.png"] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(buttonActionWeiBoXL:) forControlEvents:UIControlEventTouchUpInside];
    [_dengLuView addSubview:button1];
    
    
    UILabel *labelWB = [[UILabel alloc] initWithFrame:CGRectMake(button.frame.size.width  + [UIScreen mainScreen].bounds.size.width/3 - 80 + 60, 225, 50, 30)];
    labelWB.text= @"新浪微博";
    labelWB.textColor = [UIColor whiteColor];
    labelWB.backgroundColor = [UIColor clearColor];
    labelWB.font = [UIFont systemFontOfSize:12];
    
    [_dengLuView addSubview:labelWB];

    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.frame = CGRectMake(button.frame.size.width  + [UIScreen mainScreen].bounds.size.width/3 - 80 + 60 + button1.frame.size.width + 60, 180, 50, 50);
    [button2 setBackgroundImage:[UIImage imageNamed:@"iconfont-QQ.png"] forState:UIControlStateNormal];
    [button2 addTarget:self action:@selector(buttonActionQQ:) forControlEvents:UIControlEventTouchUpInside];
    [_dengLuView addSubview:button2];
    
    UILabel *labelQQ = [[UILabel alloc] initWithFrame:CGRectMake(button.frame.size.width  + [UIScreen mainScreen].bounds.size.width/3 - 80 + 60 + button1.frame.size.width + 60, 225, 50, 30)];
    labelQQ.text= @"腾讯微博";
    labelQQ.textColor = [UIColor whiteColor];
    labelQQ.backgroundColor = [UIColor clearColor];
    labelQQ.font = [UIFont systemFontOfSize:12];
    
    [_dengLuView addSubview:labelQQ];
    
    UIView *VIEW1 = [[UIView alloc] initWithFrame:CGRectMake(button.frame.size.width  + [UIScreen mainScreen].bounds.size.width/3 - 80 + 30, 185, 1, 45)];
    VIEW1.backgroundColor = [UIColor whiteColor];
    
    [_dengLuView addSubview:VIEW1];
    
    
    UIView *VIEW2 = [[UIView alloc] initWithFrame:CGRectMake(button.frame.size.width  + [UIScreen mainScreen].bounds.size.width/3 - 80 + 60 + button1.frame.size.width + 30, 185, 1, 45)];
    VIEW2.backgroundColor = [UIColor whiteColor];
    
    [_dengLuView addSubview:VIEW2];
    
 
    
    UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width - 100)/2, 300, 100, 50)];
   
    label4.text = @"请登录";
    label4.textAlignment = NSTextAlignmentCenter;
    label4.layer.borderColor = [UIColor whiteColor].CGColor;
    label4.layer.borderWidth = 1;
    label4.layer.cornerRadius = 20;
    label4.layer.masksToBounds = YES;
    label4.font = [UIFont systemFontOfSize:20];
    label4.textColor = [UIColor whiteColor];
    [_dengLuView addSubview:label4];
    [label4 release];
    
    
    
    
    

    
    //左上角返回去
    UIButton *buttonFanHui = [UIButton buttonWithType:UIButtonTypeCustom];
    buttonFanHui.frame = CGRectMake(30, 30, 30, 30);
    
    [buttonFanHui setImage:[UIImage imageNamed:@"iconfont-jiantouzuo-2.png"] forState:UIControlStateNormal];
    
    [buttonFanHui addTarget:self action:@selector(buttonFanHuiAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self addSubview:buttonFanHui];
    
    
    
    
    
}
//返回button方法
- (void)buttonFanHuiAction:(UIButton *)button{
    [self removeFromSuperview];
}
- (void)buttonCancle:(UIButton *)button{
    [UIView animateWithDuration:0.2 animations:^{
        _view.frame = CGRectMake(3, self.frame.size.height, self.frame.size.width - 6, 200);
    }];
    
    NSLog(@"取消");
}
- (void)buttonActionQQ:(UIButton *)button{
    NSLog(@"腾讯微博");
    [[NSNotificationCenter defaultCenter] postNotificationName:@"tengxunweibo" object:nil];
    [self removeFromSuperview];
    
}

- (void)buttonActionWeiBoXL:(UIButton *)button{
    NSLog(@"新浪微博");
    
    [self removeFromSuperview];
  
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
   
    [center postNotificationName:@"jump" object:nil];
   
}



- (void)buttonActionWeiXin:(UIButton *)button{
    NSLog(@"人人登陆");
    [[NSNotificationCenter defaultCenter] postNotificationName:@"renrenDengLu" object:nil];
    [self removeFromSuperview];
}

@end
